//package com.ellecity06.cwhiskymall.di
//
//import com.ellecity06.common.BuildConfig
//import com.ellecity06.cwhiskymall.http.ApiService
//import com.ellecity06.cwhiskymall.http.ServerConfig
//import com.ellecity06.cwhiskymall.http.interceptor.CommonHeaderInterceptor
//import dagger.Provides
//import okhttp3.OkHttpClient
//import okhttp3.logging.HttpLoggingInterceptor
//import retrofit2.Retrofit
//import retrofit2.converter.gson.GsonConverterFactory
//import java.util.concurrent.TimeUnit
//import javax.inject.Singleton
//
///**
// * @author ellecity06
// * @time 2023/4/14 17:25
// * @des
// */
////@Module
////@InstallIn(SingletonComponent::class)
//object NetworkModule {
//    /**
//     * @Provides 常用于被 @Module 注解标记类的内部的方法，并提供依赖项对象。
//     * @Singleton 提供单例
//     */
//    @Provides
//    @Singleton
//    fun provideOkHttpClient(): OkHttpClient {
//        val logging = HttpLoggingInterceptor()
//        if (BuildConfig.DEBUG) {
//            logging.level = HttpLoggingInterceptor.Level.BODY
//        } else {
//            logging.level = HttpLoggingInterceptor.Level.BASIC
//        }
//        return OkHttpClient.Builder()
//            .readTimeout(ServerConfig.TIME_OUT, TimeUnit.SECONDS)
//            .connectTimeout(ServerConfig.TIME_OUT, TimeUnit.SECONDS)
//            .addInterceptor(CommonHeaderInterceptor())
//            .addInterceptor(logging)
//            .build()
//    }
//
//    @Provides
//    @Singleton
//    fun provideRetrofit(okHttpClient: OkHttpClient): Retrofit {
//        return Retrofit.Builder()
//            .client(okHttpClient)
//            .baseUrl(ServerConfig.baseHost)
//            .addConverterFactory(GsonConverterFactory.create())
//            .build()
//    }
//
//    @Provides
//    @Singleton
//    fun provideApiService(retrofit: Retrofit): ApiService {
//        return retrofit.create(ApiService::class.java)
//    }
//
//}